package com.xjy.controller;


import com.xjy.model.auto.RoleInfo;
import com.xjy.model.auto.UserInfo;
import com.xjy.service.IRoleInfoService;
import com.xjy.service.impl.RoleInfoServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 权限表 前端控制器
 * </p>
 *
 * @author 达瓦里氏
 * @since 2021-11-10
 */
@RestController
@RequestMapping("/role-info")
public class RoleInfoController {

    @Autowired
    IRoleInfoService iRoleInfoService;

    /*查询用户*/
    @GetMapping("/getRole")
    public List<RoleInfo> getRole(){
        return iRoleInfoService.list();
    }

    /*通过id查询用户*/
    @GetMapping("/getRoleById/{id}")
    public RoleInfo getRoleById(@PathVariable("id") int id){
        return iRoleInfoService.getById(id);
    }

    /*修改用户*/
    @PostMapping("/updateRole")
    public void updateRole(@RequestBody RoleInfo roleInfo){
        iRoleInfoService.updateById(roleInfo);
    }

    /*添加用户*/
    @PostMapping("/setRole")
    public void setRole(@RequestBody RoleInfo roleInfo){
        iRoleInfoService.save(roleInfo);
    }



    /*删除用户*/
    @PostMapping("/deletedById/{id}")
    public boolean deleted(@PathVariable("id") int id){
        return iRoleInfoService.removeById(id);
    }

}
